<?php

use Dcat\Admin\Grid;
use Dcat\Admin\Form;
use Dcat\Admin\Show;

/**
 * Dcat-admin - admin builder based on Laravel.
 * @author jqh <https://github.com/jqhph>
 *
 * Bootstraper for Admin.
 *
 * Here you can remove builtin form field:
 *
 * extend custom field:
 * Dcat\Admin\Form::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Column::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Filter::extend('php', PHPEditor::class);
 *
 * Or require js and css assets:
 * Admin::css('/packages/prettydocs/css/styles.css');
 * Admin::js('/packages/prettydocs/js/main.js');
 *
 */
Grid::resolving(function (Grid $grid) {
    $grid->addTableClass(['table-text-center']);
    $grid->paginate(10);
    $grid->scrollbarX();
    $grid->toolsWithOutline(false);
    $grid->disableViewButton(); //关闭显示按钮
    $grid->disableCreateButton(); //关闭新增按钮
    $grid->disableEditButton();  //关闭编辑按钮
    $grid->disableDeleteButton(); //关闭删除按钮
    $grid->disableRowSelector(); //关闭行选择器
    $grid->setDialogFormDimensions('60%', '70%');
    $grid->actions(function (Grid\Displayers\Actions $actions) {
        $actions->disableView();
        $actions->disableQuickEdit();
    });

});

Show::resolving(function (Show $show) {
    $show->panel()->tools(function ($tools) {
        # 隐藏编辑按钮
        $tools->disableEdit();

        # 隐藏列表按钮
        $tools->disableList();

        # 隐藏删除按钮
        $tools->disableDelete();

        // 显示快捷编辑按钮
        $tools->showQuickEdit();
    });
});

Form::resolving(function (Form $form) {
//    // 去除整个工具栏内容
//    $form->disableHeader();
//
//    // 去除跳转列表按钮
//    $form->disableListButton();
//
//    // 去除跳转详情按钮
//    $form->disableViewButton();
//
//    // 去除删除按钮
//    $form->disableDeleteButton();

    // 去除整个底部内容
//    $form->disableFooter();

    // 去除提交按钮
//    $form->disableSubmitButton();

    // 去除重置按钮
//    $form->disableResetButton();

    // 去除查看按钮
    $form->disableViewCheck();

    // 去除继续编辑按钮
    $form->disableEditingCheck();

    // 去除继续创建按钮
    $form->disableCreatingCheck();
//
//    // 设置`查看`默认选中
//    $form->defaultViewChecked();
//
//    // 设置`继续编辑`默认选中
//    $form->defaultEditingChecked();
//
//    // 设置`继续创建`默认选中
//    $form->defaultCreatingChecked();
});
